<ui:composition template="/WEB-INF/templates/defaultLayout.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core">

	<ui:define name="title">
		#{lang.getTrans("ui.mobile.user.title")}
	</ui:define>
	<ui:define name="layoutCenter">
		<h:form>
			<p:growl id="growl" showDetail="true"/>		
			<p:breadCrumb>
				<p:menuitem value="#{lang.getTrans('ui.mobile.common.bread.home')}" url="/home.xhtml"/>
				<p:menuitem value="#{lang.getTrans('ui.mobile.common.bread.user')}" url="/crud/user/userList.xhtml"/>
				<p:menuitem value="#{lang.getTrans('ui.mobile.common.bread.editar')}" url="/crud/user/userForm.xhtml"/>
			</p:breadCrumb>
			<p:panel id="panel" header="#{lang.getTrans('ui.mobile.user.cadastre')}">		
				<h:panelGrid columns="2">

					<h:outputLabel value="#{lang.getTrans('ui.mobile.user.name')}" for="cdUser" />
					<p:inputText id="cdUser" value="#{usersBean.user.cdUser}" required="true" 
						requiredMessage="#{lang.getTrans('ui.mobile.user.name.obrigatorio')}"
						size="50" maxlength="70" />

					<h:outputLabel value="#{lang.getTrans('ui.mobile.user.login')}" for="cdLogin" />
					<p:inputText id="cdLogin" value="#{usersBean.user.cdLogin}" required="true"
						requiredMessage="#{lang.getTrans('ui.mobile.user.login.obrigatorio')}"
						size="30" maxlength="50" />

					<h:outputLabel value="#{lang.getTrans('ui.mobile.user.password')}" for="cdPassword" />
					<p:password id="cdPassword" value="#{usersBean.user.cdPassword}"
						requiredMessage="#{lang.getTrans('ui.mobile.user.password.obrigatorio')}"
						required="true" size="30" maxlength="50" autocomplete="off"/>

					<h:outputLabel value="#{lang.getTrans('ui.mobile.user.confirm.password')}" for="cdConfirmPassword" />
					<p:password id="cdConfirmPassword" value="#{usersBean.user.cdConfirmPassword}" 
						size="30" required="true" maxlength="50" autocomplete="off"
						requiredMessage="#{lang.getTrans('ui.mobile.user.confirm.password.obrigatorio')}" />

					<h:outputLabel value="#{lang.getTrans('ui.mobile.user.email')}" />
					<p:inputText id="cdEmail" value="#{usersBean.user.cdEmail}" size="50" maxlength="70" />

					<h:outputLabel value="#{lang.getTrans('ui.mobile.user.phone')}" />
					<p:inputMask id="cdPhone" value="#{usersBean.user.cdPhone}"
						size="30" maxlength="30" mask="(99) 9999-9999" />
						
					<h:outputLabel value="#{lang.getTrans('ui.mobile.user.usergroup')}" />
					<p:selectOneMenu id="userGroup" value="#{usersBean.user.userGroup}" required="true" 
						requiredMessage="#{lang.getTrans('ui.mobile.user.group.obrigatorio')}">
						<f:selectItem itemLabel="Selecione" itemValue="" />
						<f:selectItems value="#{usersBean.usersGroups}" itemValue="#{usersBean.user.userGroup}"/>
						<f:converter converterId="userGroup" />
					</p:selectOneMenu>

				</h:panelGrid>
			</p:panel>
			<p:blockUI block="panel" trigger="btSub"/>
			<p:panel style="text-align:center;">
				<p:inputText id="idUser" type="hidden" value="#{usersBean.user.idUser}" />
				<h:inputHidden id="nrVersion" value="#{usersBean.user.nrVersion}" />
				<p:commandButton id="btSub" value="#{lang.getTrans('ui.mobile.common.save')}"
					type="submit" action="#{usersBean.adicionar}" update="growl" />
				<p:button value="#{lang.getTrans('ui.mobile.common.cancel')}" outcome="userList" />
			</p:panel>
		</h:form>
	</ui:define>
</ui:composition>
